-
Notifications
You must be signed in to change notification settings - Fork 344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Use file input in payForBlobs CLI to allow to submit multiple blobs #2856
Conversation
Note Reviews PausedUse the following commands to manage reviews:
TipsChat with CodeRabbit Bot (
|
@coderabbitai pause |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #2856 +/- ##
=======================================
Coverage 19.16% 19.16%
=======================================
Files 142 142
Lines 17291 17285 -6
=======================================
Hits 3313 3313
+ Misses 13676 13670 -6
Partials 302 302 ☔ View full report in Codecov by Sentry. |
@bao1029p hey gud ser can i have permision to push some code to this PR |
yes plss feel free to contribute to this PR |
thanks @sontrinh16 for the help, i think we are close command work now, will do some testing |
i think this is a rough working version for now, happy to change any logic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dope left a few comments on things I think we should handle but otherwise this is a really great start. thanks for doing this @bao1029p !!
x/blob/client/cli/payforblob.go
Outdated
shareVersion, _ := cmd.Flags().GetUint8(FlagShareVersion) | ||
blob, err := types.NewBlob(namespace, rawblob, shareVersion) | ||
if err != nil { | ||
fmt.Printf("failure to create blob with hex blob value %s: %s", hexStr, err.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[blocking]
as is would this submit a transaction without the blob that failed? if that's the case then I think we need to return with error. that could be immediatly or using something like multierror
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes agreed will update this
x/blob/client/cli/payforblob.go
Outdated
if len(args) < 2 { | ||
return fmt.Errorf("PayForBlobs requires two arguments: namespaceID and blob") | ||
if len(args) < 1 { | ||
return fmt.Errorf("PayForBlobs requires one arguments: path to blob.json") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[blocking]
I think there's a way to avoid a breaking change, and we should pursue that. for example we could use a flag to indicate that its pointing to json file (or accepted piped input etc). we could even check if the input has the last five characters equal to ".json" and then proceed to try and parse a json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added the check, thanks for the suggestion
x/blob/client/cli/payforblob.go
Outdated
// FlagNamespaceVersion allows the user to override the namespace version when | ||
// submitting a PayForBlob. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[blocking] this GoDoc isn' related to the flag it's documenting. It should look something like:
// FlagBlobsFilePath allows the user to...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated as requested
x/blob/client/cli/payforblob.go
Outdated
|
||
// FlagNamespaceVersion allows the user to override the namespace version when | ||
// submitting a PayForBlob. | ||
FlagBlobsFilePath = "blobs-file-path" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[blocking] this flag appears unused. I think the command below should only read blobs from a file path if the optional flag is provided.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i have move the file input to a optional flag instead of argument
x/blob/client/cli/payforblob.go
Outdated
) | ||
|
||
func CmdPayForBlob() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "PayForBlobs namespaceID blob", | ||
Use: "PayForBlobs [namespaceID, blob] [path/to/blob.json]", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[blocking] this usage statement is a bit confusing. The []
usually describes a optional group. Here both groups are optional but that's not really the case. The command accepts one or the other.
I think we should take a step back and design the user experience.
Non-breaking approach
IMO this command should accept one namespaceID and blob. Ex.
celestia-appd tx blob PayForBlobs namespaceID blob
or multiple blobs
celestia-appd tx blob PayForBlobs --input-file path/to/blobs.json
Breaking approach
We split this into two commands (PayForBlob
and PayForBlobs
) and remove the aliases
celestia-appd tx blob PayForBlob namespaceID blob
celestia-appd tx blob PayForBlobs path/to/blobs.json
x/blob/client/cli/payforblob.go
Outdated
Example: "celestia-appd tx blob PayForBlobs path/to/blob.json \\\n" + | ||
"\t--chain-id private \\\n" + | ||
"\t--from validator \\\n" + | ||
"\t--keyring-backend test \\\n" + | ||
"\t--fees 21000utia \\\n" + | ||
"\t--yes", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[blocking] if we do the non-breaking approach where this command supports both one blob and multiple blobs, then this Example section should contain both examples
$ celestia-appd tx blob PayForBlobs --help
<truncated>
Examples:
celestia-appd tx blob PayForBlobs 0x00010203040506070809 0x48656c6c6f2c20576f726c6421 \
--chain-id private \
--from validator \
--keyring-backend test \
--fees 21000utia \
--yes
celestia-appd tx blob PayForBlobs --input-file path/to/blobs.json \
--chain-id private \
--from validator \
--keyring-backend test \
--fees 21000utia \
--yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added as suggested
x/blob/client/cli/payforblob.go
Outdated
Short: "Pay for a data blobs to be published to Celestia.", | ||
Long: "Pay for a data blobs to be published to Celestia.\n" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Short: "Pay for a data blobs to be published to Celestia.", | |
Long: "Pay for a data blobs to be published to Celestia.\n" + | |
Short: "Pay for data blob(s) to be published to Celestia.", | |
Long: "Pay for data blob(s) to be published to Celestia.\n" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
x/blob/client/cli/payforblob.go
Outdated
Short: "Pay for a data blobs to be published to Celestia.", | ||
Long: "Pay for a data blobs to be published to Celestia.\n" + | ||
"User can use namespaceID and blob or path to a json file as argument" + | ||
`Where blob.json contains: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Suggestion] To enhance the user experience, it would be beneficial to consider the implementation of flexible file naming conventions, rather than restricting to a specific file name like blob.json
. This can be achieved by allowing users to include their chosen file name in the filepath, which then can be parsed accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yeah, i think i need to specify that blob.json is an example file name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only one comment from the linter otherwise lgtm. thanks @bao1029p
x/blob/client/cli/payforblob.go
Outdated
if len(args) < 2 { | ||
return fmt.Errorf("PayForBlobs requires two arguments: namespaceID and blob") | ||
return fmt.Errorf("PayForBlobs requires two argument: namespaceID and blob") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we're going to use fmt.Errorf, then we should include something to format in the string other wise I think the linter is going to block us
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated as request
Just as an aside, I don't know why we use camel case for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic work! Thanks for persisting through multiple rounds of review. I have one nit and then this LGTM
Close #2434
Changes made
payForBlob
commandparseSubmitBlobs
to parse content from the file to array of definedblobJSON
. Each blobJSON contain a namespaceID and blob in hex encoded format ( can modify what the user can put in the file later on, this need further conversation on this )broadcastPFB
func to accept multiple blobs insteadTesting
test the command with single-node script running and got this result ( thanks @sontrinh16 for providing the test result )
using the test_blob.json file contain:
{ "Blobs": [ { "namespaceId": "0x00010203040506070809", "blob": "0x48656c6c6f2c20576f726c6421" }, { "namespaceId": "0x00010203040506070809", "blob": "0x48656c6c6f2c20576f726c6421" } ] }
Checklist